@echo off
echo 诊断Kotlin编译问题...
echo.

REM 检查文件存在性
echo 检查项目文件结构...
echo.

echo [1/7] 检查主要Activity文件...
if exist "app\src\main\java\com\example\appusagestats\MainActivity.kt" (
    echo ✓ MainActivity.kt 存在
) else (
    echo ✗ MainActivity.kt 缺失
)

if exist "app\src\main\java\com\example\appusagestats\TimeSlotActivity.kt" (
    echo ✓ TimeSlotActivity.kt 存在
) else (
    echo ✗ TimeSlotActivity.kt 缺失
)

if exist "app\src\main\java\com\example\appusagestats\AppDetailActivity.kt" (
    echo ✓ AppDetailActivity.kt 存在
) else (
    echo ✗ AppDetailActivity.kt 缺失
)

echo.
echo [2/7] 检查模型类文件...
if exist "app\src\main\java\com\example\appusagestats\model\AppUsageInfo.kt" (
    echo ✓ AppUsageInfo.kt 存在
) else (
    echo ✗ AppUsageInfo.kt 缺失
)

if exist "app\src\main\java\com\example\appusagestats\model\TimeSlot.kt" (
    echo ✓ TimeSlot.kt 存在
) else (
    echo ✗ TimeSlot.kt 缺失
)

if exist "app\src\main\java\com\example\appusagestats\model\UsageEvent.kt" (
    echo ✓ UsageEvent.kt 存在
) else (
    echo ✗ UsageEvent.kt 缺失
)

echo.
echo [3/7] 检查管理器类...
if exist "app\src\main\java\com\example\appusagestats\manager\UsageStatsManager.kt" (
    echo ✓ UsageStatsManager.kt 存在
) else (
    echo ✗ UsageStatsManager.kt 缺失
)

echo.
echo [4/7] 检查适配器类...
if exist "app\src\main\java\com\example\appusagestats\adapter\AppUsageAdapter.kt" (
    echo ✓ AppUsageAdapter.kt 存在
) else (
    echo ✗ AppUsageAdapter.kt 缺失
)

if exist "app\src\main\java\com\example\appusagestats\adapter\UsageDetailAdapter.kt" (
    echo ✓ UsageDetailAdapter.kt 存在
) else (
    echo ✗ UsageDetailAdapter.kt 缺失
)

echo.
echo [5/7] 检查资源文件...
if exist "app\src\main\AndroidManifest.xml" (
    echo ✓ AndroidManifest.xml 存在
) else (
    echo ✗ AndroidManifest.xml 缺失
)

if exist "app\src\main\res\layout\activity_main.xml" (
    echo ✓ activity_main.xml 存在
) else (
    echo ✗ activity_main.xml 缺失
)

if exist "app\src\main\res\layout\activity_time_slot.xml" (
    echo ✓ activity_time_slot.xml 存在
) else (
    echo ✗ activity_time_slot.xml 缺失
)

echo.
echo [6/7] 检查构建配置文件...
if exist "app\build.gradle" (
    echo ✓ app/build.gradle 存在
) else (
    echo ✗ app/build.gradle 缺失
)

if exist "build.gradle" (
    echo ✓ build.grady 存在
) else (
    echo ✗ build.gradle 缺失
)

if exist "gradle.properties" (
    echo ✓ gradle.properties 存在
) else (
    echo ✗ gradle.properties 缺失
)

echo.
echo [7/7] 进行编译测试...
call gradlew compileDebugKotlin --no-daemon --quiet

if %errorlevel% equ 0 (
    echo ✅ Kotlin编译成功！
    echo.
    echo 所有文件都存在且编译无错误
    echo 可以继续构建APK
) else (
    echo ❌ Kotlin编译失败
    echo 请检查上述文件是否存在且内容正确
)

pause
